# 练习2：字符串处理：
# 		现有字符串 msg = "hello python ni hao"  将其中所有的空格改为下划线，得到新字符串："hello_python_ni_hao"
# 		现有字符串 msg = "hello python ni hao" 统计字符串"o" 出现的次数和位置
# 		现有字符串 msg = "hello python ni hao"  删除字符串中所有的空格，并打印结果："hellopythonnihao"

# No.1
print("_".join("hello python ni hao".split()))

# No.2
msg = "hello python ni hao"
count = 0
pos_list = []
for i, c in enumerate(msg):
    if c == "o":
        count += 1
        pos_list.append(i)

print("o一共有%d个" % count)
print(pos_list)

# No.3
print("".join("hello python ni hao".split()))